import request from "@/utils/request"

export function login(params){
  return request({
    url:`/user/login`,
    method:'get',
    params
  })
}

export function register(data){
  return request({
    url:'/user/register',
    method:'post',
    data
  })
}

export function getUserInfo(params){
  return request({
    url:'/user/getInfo',
    method:'get',
    params
  })
}

export function updateUser(data){
  if(data.type == 0){
    return request({
      url:'/user/updateDoctor',
      method:'post',
      data
    })
  }else {
    return request({
      url:'/user/updatePatient',
      method:'post',
      data
    })
  }
}

export function userRecharge(params){
  return request({
    url:'/user/recharge',
    method:'get',
    params
  })
}

export function getUserOrderList(uid){
  return request({
    url:`/user/getOrder?id=${uid}`,
    method:'get'
  })
}

export function cancelOrder(params){
  return request({
    url:`/user/updateOrder`,
    method:'get',
    params
  })
}

export function getMedicineList(id){
  return request({
    url:`/user/getRecommendMedicine?id=${id}`,
    method:'get'
  })
}

export function getDoctorList(outpatient){
  return request({
    url:`/user/getDoctor?outpatient=${outpatient}`,
    method:'get'
  })
}

export function userOrder(data) {
  return request({
    url:'/user/order',
    method:'post',
    data
  })
}

export function getDoctorFree(params){
  return request({
    url:'/user/getFreeTime',
    method:'get',
    params
  })
}